<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title> <#include "/jeecms_sys/head.html"/>
<script type="text/javascript">
	var objectArray;
	$(function() {
		objectArray = eval($("#array").val());
		$("select[name='ctgId']").bind("change", changevalue);
	});

	function changevalue() {
		var select = $("select[name='userId']");
		select.empty();
		for ( var i = 0; i < objectArray.length; i++) {
			if (this.value == objectArray[i].ctgId) {
				if (objectArray[i].uId) {
					select.append($("<option value="+objectArray[i].uId+">"
							+ objectArray[i].uName + "</option>"));
				} else {
					select.append($("<option value=''><暂无></option>"));
				}
			}
		}

	}

	function send_email_info() {
		if (confirm('确认发送')) {
			var userId = document.getElementsByName("userId")[0].value
			var content = document.getElementsByName("content")[0].value;
			var title = document.getElementsByName("title")[0].value;
			content = content.replace(/%/g, "%25");
			content = content.replace(/\&/g, "%26");
			content = content.replace(/\+/g, "%2B");
			var data = "userId=" + userId + "&content=" + content + "&title="
					+ title;
			$.ajax({
				type : "POST",
				url : "/SendSMSServlet",
				data : data,
				success : function(msg) {
					alert(eval(msg));
				}
			});
		}
	}
	window.onload = function (){
		var ctgObj = document.getElementsByName("ctgId")[0];
		var ctgOpt = ctgObj.options;
		var len = ctgOpt.length;
		var hidCtgIdStr = $("[name=hidCtgId]").val();
		for(var i = 0 ; i < len ; i++) {
			if(ctgOpt[i].value == hidCtgIdStr) {
				ctgOpt[i].selected="selected";
			}
		}
	};
</script>
</head>
<body>
	<div class="body-box">
		<div class="rhead">
			<div class="rpos"><@s.m "global.position"/>: <@s.m
				"cmsGuestbook.function"/> - <@s.m "global.edit"/></div>
			<form class="ropt">
				<input type="submit" value="<@s.m "global.backToList"/>"
				onclick="this.form.action='v_list.do';"/>
			</form>
			<div class="clear"></div>
		</div>
		<@p.form id="jvForm" action="o_update.do" labelWidth="22"> 
		<@p.hidden    id="array" value=objectArray/> 
		<@p.hidden name="isReply" value="false"/> 
		<@p.select colspan="1" label="cmsGuestbook.ctg"  name="ctgId" value=name list=ctgList listKey="id" id="ctgId" listValue="name"  required="true"/>
		 <@p.text  colspan="1" label="受理编号" name="number" value=cmsGuestbook.number maxlength="50" width="20"/> 
		<@p.hidden  name="hidCtgId" value=cmsGuestbook.ctg.id />
		
		<@p.tr/>
		 <@p.text colspan="2" label="cmsGuestbook.title" name="title" value=cmsGuestbook.title size="70" maxlength="255"/><@p.tr/>
		 <@p.textarea colspan="2"  label="cmsGuestbook.content" name="content" value=cmsGuestbook.content rows="5" cols="70" maxlength="255"/>
		<@p.tr/> 
		 <@p.textarea colspan="2" label="cmsGuestbook.reply" name="reply" value=cmsGuestbook.reply rows="5" cols="70" maxlength="255"/>
		<@p.tr/>
		  <@p.text colspan="1" width="50" label="cmsGuestbook.email" name="email" value=cmsGuestbook.email maxlength="100"/>
		  <@p.text colspan="1" width="50" label="cmsGuestbook.phone" name="phone" value=cmsGuestbook.phone maxlength="100"/>
		<@p.tr/> 
		 <@p.text  colspan="1" label="cmsGuestbook.qq" name="qq" value=cmsGuestbook.qq maxlength="50"/> 
		<@p.select colspan="1" label="责任人" name="userId" value=cmsUser.id list=userList listKey="id" listValue="username"
		required="true"/>
		
		<@p.tr/> 
		<@p.radio colspan="1" width="50" label="cmsGuestbook.checked" name="checked" value=cmsGuestbook.checked
		list={"true":"global.true","false":"global.false"}/>
		 <@p.radio colspan="1" width="50" label="cmsGuestbook.recommend" name="recommend" value=cmsGuestbook.recommend
		list={"true":"global.true","false":"global.false"}/>
		<@p.tr/> <@p.td colspan="2"> <@p.hidden name="id" value=cmsGuestbook.id/> 
		<@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/> &nbsp; 
		<input	type="button" value="发送信息" onclick="send_email_info()" /> </@p.td>
		</@p.form>
	</div>
</body>
</html>